//
//  ServerEventsViewController.h
//  ws-mgmt-client
//
//  Created by Cliff Duffey on 9/14/09. Mage Labs.
//

#import <UIKit/UIKit.h>
#import "MBProgressHUD.h"

typedef enum _request_type {systemLog, appLog, securityLog} request_type;

@interface ServerEventsViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
	NSMutableArray *events; //data source for the table; populated by the event log of the server
	NSMutableArray *eventColor; //Determines the color of the cell based on the event type
	
	NSUInteger serverListIndex; //the index of the servers events
	
	NSMutableData *webData; //Used to store data from the HTTP response
	NSMutableString *enumerationContext; //Stores data from the designated XML element pulled out of the HTTP/SOAP response
	NSXMLParser *xmlParser; //Parses the SOAP result
	NSXMLParser *xmlEventsParser; //Parses the SOAP result

	BOOL recordResults; //Tells the XML parser delegate function whether to store the data from the XML element in soapResult
	BOOL enumerateSessionEstablished; //For the HTTP delegates to determine which SOAP message to send
	
	NSMutableString *logEventType; //The type of event pulled, e.g., warning, error, informational
	BOOL recordTypeResults; //Tells the parser to put the data in the current element in logEventType
	
	NSMutableString *logEventMessage; //A description of the pulled event;
	BOOL recordMessageResults; //Tells the parser to put the data in the current element in logEventMessage
	
	NSMutableString *logRecordNumber; //Determines which record number an event is
	BOOL recordRecordNumberResults; //Tells parser to put the data in the current element in logRecordNumber
	
	BOOL fault; //True if a fault SOAP message was received
	NSMutableString *faultMessage; //Holds the message of the fault if one occurs
	
	NSString *serverURL; //IP address of the WS-MGMT server
	NSString *port; //Port # of the WS-MGMT server
	NSString *credentials; //credentials for accessing the WS-MGMT server
	
	request_type requestType; //Whether we're going to query the events, system or security log. Initialized at allocation.
		
}

@property (nonatomic, retain) NSMutableArray *events;
@property (nonatomic, retain) NSMutableArray *eventColor;

@property (nonatomic, readwrite) NSUInteger serverListIndex;

@property(nonatomic, retain) NSMutableData *webData;
@property(nonatomic, retain) NSMutableString *enumerationContext;
@property(nonatomic, retain) NSXMLParser *xmlParser;
@property(nonatomic, retain) NSXMLParser *xmlEventsParser;

@property(nonatomic, readwrite) BOOL enumerateSessionEstablished;

@property(nonatomic, retain) NSMutableString *logEventType;
@property(nonatomic, readwrite) BOOL recordTypeResults;
@property(nonatomic, retain) NSMutableString *logEventMessage;
@property(nonatomic, readwrite) BOOL recordMessageResults;
@property(nonatomic, retain) NSMutableString *logRecordNumber;
@property(nonatomic, readwrite) BOOL recordRecordNumberResults;

@property(nonatomic, retain) NSMutableString *faultMessage;
@property(nonatomic, readwrite) BOOL fault;

@property(nonatomic, retain) NSString *serverURL;
@property(nonatomic, retain) NSString *credentials;
@property(nonatomic, readwrite) request_type requestType;

-(void)sendMessage;
@end
